package com.example.myapplication;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import java.util.ArrayList;
import java.util.List;

//public class MainActivity4 extends AppCompatActivity {
//    RecyclerView recyclerView;
//    private List<Fruit> fruitList = new ArrayList<Fruit>();
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main4);
//        initView();
//        initFruits();
//        //4、创建适配器
//        FruitAdapter adapter = new FruitAdapter(fruitList);
//        //5、让数据显示在控件上
//        LinearLayoutManager layoutManager=new LinearLayoutManager(this);
//        recyclerView.setLayoutManager(layoutManager);
//        recyclerView.setAdapter(adapter);
//    }
//    //3、准备数据-代码
//    private void initFruits() {
//        for (int i = 0; i < 25; i++) {
//            Fruit apple = new Fruit("陕西红富士", R.drawable.dasongshaonianzhi, "优质苹果 香甜爽口", "¥20元 / kg");
//            fruitList.add(apple);
//            Fruit shiliu = new Fruit("大理石榴", R.drawable.kaiduan, "新鲜石榴 全新上市", "¥15元 / kg");
//            fruitList.add(shiliu);
//            Fruit chengzi=new Fruit("台湾茂谷柑",R.drawable.zuihaodewomen,"浓甜无渣 瓣瓣多汁","¥49.9元 / kg");
//            fruitList.add(chengzi);
//            Fruit mangguo=new Fruit("新鲜大青芒",R.drawable.bianchengni,"精选大果 肥厚饱满","¥29.9元 / kg");
//            fruitList.add(mangguo);
//            Fruit putao=new Fruit("巨峰葡萄",R.drawable.qingyunian,"爆汁超甜 新鲜采摘","¥19.9元 / kg");
//            fruitList.add(putao);
//            Fruit boluo=new Fruit("台湾菠萝",R.drawable.langyabang,"香甜可口 汁水浓厚","¥38.9元 / kg");
//            fruitList.add(boluo);
//            Fruit xigua=new Fruit("早春红玉西瓜",R.drawable.helihuating,"皮薄肉甜 物美价廉","¥28.8元 / kg");
//            fruitList.add(xigua);
//        }
//
//    }
//
//    private void initView() {
//        recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
//    }
//}
public class MainActivity extends AppCompatActivity {
    Button btn_home,btn_tv,btn_dynamic,btn_mine;
    private List<Teleplay> tvList = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //initView();
        //btn_home();
        //btn_tv();
        //btn_dynamic();
        //btn_mine();
        initTeleplay();
        RecyclerView recyclerView = findViewById(R.id.recyclerview);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
//        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);  //设置方向
        recyclerView.setLayoutManager(layoutManager);
        TeleplayAdapter adapter = new TeleplayAdapter(tvList);
        recyclerView.setAdapter(adapter);
    }
//    private void initView() {
//        btn_home=findViewById(R.id.button_home);
//        btn_tv=findViewById(R.id.button_tv);
//        btn_dynamic=findViewById(R.id.button_dynamic);
//        btn_mine=findViewById(R.id.button_mine);
//    }
    private void initTeleplay() {
        for (int i = 0; i < 2; i++) {
            Teleplay dasongshaonianzhi = new Teleplay("大宋少年志", R.drawable.dasongshaonianzhi);
            tvList.add(dasongshaonianzhi);
            Teleplay kaiduan = new Teleplay("开端", R.drawable.kaiduan);
            tvList.add(kaiduan);
            Teleplay zuihaodewomen = new Teleplay("最好的我们", R.drawable.zuihaodewomen);
            tvList.add(zuihaodewomen);
            Teleplay bianchengni = new Teleplay("变成你的那一天", R.drawable.bianchengni);
            tvList.add(bianchengni);
            Teleplay qingyunian = new Teleplay("庆余年", R.drawable.qingyunian);
            tvList.add(qingyunian);
            Teleplay langyabang = new Teleplay("琅琊榜", R.drawable.langyabang);
            tvList.add(langyabang);
            Teleplay helihuating = new Teleplay("鹤唳华亭", R.drawable.helihuating);
            tvList.add(helihuating);
//            Teleplay pineapple = new Teleplay("pineapple", R.drawable.helihuating);
//            tvList.add(pineapple);
//            Teleplay pineapple = new Teleplay("pineapple", R.drawable.helihuating);
//            tvList.add(pineapple);
//            Teleplay pineapple = new Teleplay("pineapple", R.drawable.helihuating);
//            tvList.add(pineapple);
        }
    }
//    private void btn_home() {
//        btn_home.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent= new Intent();
//                intent.setClass(MainActivity.this,MainActivity3.class);
//                startActivity(intent);
//            }
//        });
//    }
//    private void btn_tv() {
//        btn_tv.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent1= new Intent();
//                intent1.setClass(MainActivity.this,MainActivity4.class);
//                startActivity(intent1);
//            }
//        });
//    }
//    private void btn_dynamic() {
//        btn_dynamic.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent2= new Intent();
//                intent2.setClass(MainActivity.this,MainActivity5.class);
//                startActivity(intent2);
//            }
//        });
//    }
//    private void btn_mine() {
//        btn_mine.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent3= new Intent();
//                intent3.setClass(MainActivity4.this,MainActivity6.class);
//                startActivity(intent3);
//            }
//        });
//    }
//    private void initView() {
//        btn_home=findViewById(R.id.button_home);
//        btn_tv=findViewById(R.id.button_tv);
//        btn_dynamic=findViewById(R.id.button_dynamic);
//        btn_mine=findViewById(R.id.button_mine);
//    }
}